import 'package:get/get.dart';
import 'package:pmviewer/global.dart';

class ServerSettingsController extends GetxController {
  String? serverAddress;
  String? serverPort;

  final count = 0.obs;

  @override
  void onInit() {
    super.onInit();
    serverAddress = settingsStorage.read(serverAddressKey);
    serverPort = settingsStorage.read(serverPortKey);
  }

  @override
  void onReady() {
    super.onReady();
  }

  @override
  void onClose() {
    super.onClose();
  }

  void increment() => count.value++;

  // 保存服务器IP和端口设置
  void save(String address, String port) async {
    String? serverAddress = address;
    await settingsStorage.write(serverAddressKey, serverAddress);
    String serverPort = port;
    await settingsStorage.write(serverPortKey, serverPort);
  }
}
